package com.sanpu.kxe.business.main.provider;

import android.content.Context;
import android.content.Intent;

import com.sanpu.kxe.business.main.bean.UserCenterOutput;
import com.sanpu.kxe.business.main.contract.MainConfig;
import com.sanpu.kxe.business.main.model.MainModel;
import com.sanpu.kxe.business.main.view.AdviceInitiateActivity;
import com.sanpu.kxe.business.main.view.CertificateHelpActivity;
import com.sanpu.kxe.business.main.view.CreditEventActivity;
import com.sanpu.kxe.business.main.view.LinkfaceOcrActivity;
import com.sanpu.kxe.business.main.view.MainActivity;
import com.sanpu.kxe.business.main.view.SetPayPwdOneActivity;
import com.sanpu.kxe.utils.IntentTool;
import com.sanpu.kxe.utils.annotation.ModuleAnnotation;

import rx.Observable;

/**
 * Description：main模块provider
 * Created by 薛勇军 on 2018/7/10.
 */
@ModuleAnnotation(module = "kxeprovider")
public class MainProvider implements IMainProvider {

    @Override
    public Observable<UserCenterOutput> userCenter() {
        return MainModel.getInstance().userCenter();
    }

    @Override
    public void openMainActivity(Context context, boolean isFinish) {
        IntentTool.startActivity(context, MainActivity.class, isFinish);
    }

    @Override
    public void openCertificationActivity(Context context, boolean isFinish) {
        IntentTool.startActivity(context, LinkfaceOcrActivity.class, isFinish);
    }

    @Override
    public void openCertificateHelpActivity(Context context, String currentType) {
        Intent intent = new Intent();
        intent.setClass(context, CertificateHelpActivity.class);
        intent.putExtra(MainConfig.INTENT_CURRENT_TYPE, currentType);
        IntentTool.startActivity(context, intent);
    }

    @Override
    public void openAdviceInitiateActivity(Context context, String title, String type) {
        Intent intent = new Intent(context, AdviceInitiateActivity.class);
        intent.putExtra(MainConfig.INTENT_ADVICE_TITLE, title);
        intent.putExtra(MainConfig.INTENT_ADVICE_TYPE, type);
        IntentTool.startActivity(context, intent);
    }

    @Override
    public void openCreditEventActivity(Context context) {
        IntentTool.startActivity(context, CreditEventActivity.class);
    }

    @Override
    public Observable<String> sharingIntegral(String shareType) {
        return MainModel.getInstance().sharingIntegral(shareType);
    }

    @Override
    public void openSetPayPwdOneActivity(Context context, boolean isFinish) {
        Intent intent = new Intent();
        intent.setClass(context, SetPayPwdOneActivity.class);
        IntentTool.startActivity(context, intent, isFinish);
    }

    @Override
    public void openBrowserX5Activity(Context context, String url, boolean showPreLoad) {
        MainOpenProvider.getInstance().openBrowserX5Activity(context, url, showPreLoad);
    }

    @Override
    public void openBrowserX5Activity(Context context, String title, String url) {
        MainOpenProvider.getInstance().openBrowserX5Activity(context, title, url);
    }

    @Override
    public void openBrowserX5Activity(Context context, String title, String url, String referrer) {
        MainOpenProvider.getInstance().openBrowserX5Activity(context, title, url, referrer);
    }

    @Override
    public void openBrowserX5Activity(Context context, String url, boolean showTitle, boolean showPreLoad) {
        MainOpenProvider.getInstance().openBrowserX5Activity(context, url, showTitle, showPreLoad);
    }
}
